package com.ruoyi.web.controller.laiqianba.merchant;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.MerchantDataPushApibInfo;
import com.ruoyi.merchant.service.IMerchantDataPushApibInfoService;
import com.ruoyi.web.wrapper.MerchantDataPushApibInfoWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 半流程授权订单Controller
 * 
 * @author ruoyi
 * @date 2025-01-06
 */
@RestController
@RequestMapping("/merchant/pushApibInfo")
public class MerchantDataPushApibInfoController extends BaseController
{
    @Autowired
    private IMerchantDataPushApibInfoService merchantDataPushApibInfoService;

    /**
     * 查询半流程授权订单列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:pushApibInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(MerchantDataPushApibInfo merchantDataPushApibInfo)
    {
        startPage();
        List<Map<String, Object>> list = merchantDataPushApibInfoService.selectMerchantDataPushApibInfoMapList(merchantDataPushApibInfo);
        list = new MerchantDataPushApibInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出半流程授权订单列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:pushApibInfo:export')")
    @Log(title = "半流程授权订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MerchantDataPushApibInfo merchantDataPushApibInfo)
    {
        List<MerchantDataPushApibInfo> list = merchantDataPushApibInfoService.selectMerchantDataPushApibInfoList(merchantDataPushApibInfo);
        ExcelUtil<MerchantDataPushApibInfo> util = new ExcelUtil<MerchantDataPushApibInfo>(MerchantDataPushApibInfo.class);
        util.exportExcel(response, list, "半流程授权订单数据");
    }

    /**
     * 获取半流程授权订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:pushApibInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(merchantDataPushApibInfoService.selectMerchantDataPushApibInfoById(id));
    }

    /**
     * 新增半流程授权订单
     */
    @PreAuthorize("@ss.hasPermi('merchant:pushApibInfo:add')")
    @Log(title = "半流程授权订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MerchantDataPushApibInfo merchantDataPushApibInfo)
    {
        return toAjax(merchantDataPushApibInfoService.insertMerchantDataPushApibInfo(merchantDataPushApibInfo));
    }

    /**
     * 修改半流程授权订单
     */
    @PreAuthorize("@ss.hasPermi('merchant:pushApibInfo:edit')")
    @Log(title = "半流程授权订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MerchantDataPushApibInfo merchantDataPushApibInfo)
    {
        return toAjax(merchantDataPushApibInfoService.updateMerchantDataPushApibInfo(merchantDataPushApibInfo));
    }

    /**
     * 删除半流程授权订单
     */
    @PreAuthorize("@ss.hasPermi('merchant:pushApibInfo:remove')")
    @Log(title = "半流程授权订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(merchantDataPushApibInfoService.deleteMerchantDataPushApibInfoByIds(ids));
    }
}
